package org.zjvis.datascience.common.vo;

import cn.weiguangfu.swagger2.plus.annotation.ApiRequestInclude;
import lombok.Data;
import lombok.Getter;
import org.zjvis.datascience.common.dto.DashboardDTO;
import org.zjvis.datascience.common.util.DozerUtil;
import org.zjvis.datascience.common.validator.NotNullNumber;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @description 画布表 Dashboard相关VO
 * @date 2021-12-22
 */
@Data
@Getter
public class DashboardVO extends BaseVO {

    @ApiRequestInclude(groups = {IdCombo.class, UnStuck.class, Download.class})
    @NotNullNumber(message = "please specify the dashboard Id", groups = {IdCombo.class,UnStuck.class, Download.class})
    private Long id;

    @ApiRequestInclude(groups = {ProjectId.class, UnStuck.class, Download.class, publishCombo.class, IdCombo.class})
    @NotNullNumber(message = "please specify a project id", groups = {ProjectId.class, UnStuck.class, Download.class, publishCombo.class, IdCombo.class})
    private Long projectId;

    private String layout;

    private String publishLayout;

    private LocalDateTime publishTime;

    @ApiRequestInclude(groups = {publishCombo.class})
    private String publishNo;

    private Integer status;

    private String name;

    private String type;

    private Boolean isComplex;

    private Boolean showWatermark;

    /**
     * 对于复杂可视化视图，会复制一次pipeline 然后在这里存储新老taskId的对应关系
     */
    private String mappingJson;

    @ApiRequestInclude(groups = {publishCombo.class})
    private Long pipelineId;

    @ApiRequestInclude(groups = {Download.class})
    private Map<String, String> imgUrlMap;

    /**
     * 用于 画布的权限访问限制
     * 仅自己可见 传自己的用户ID
     * 全部人可见 传-1
     * 部分人可见 传指定人的userId字符串 逗号分割
     */
    private String visitorIds;

    private String backgroundImg;

    @ApiRequestInclude(groups = {Download.class})
    private String templateType;

    public DashboardDTO toDashboard() {
        DashboardDTO dashboard = DozerUtil.mapper(this, DashboardDTO.class);
        return dashboard;
    }

    /**
     * https://gitee.com/baomidou/mybatis-plus/issues/IINUI
     * 不能删除
     *
     * @return
     */
    public Boolean getIsComplex() {
        return this.isComplex;
    }

    public interface ProjectId {
    }

    public interface IdCombo {
    }


    public interface UnStuck {
    }

    public interface Download {
    }

    public interface publishCombo {
        //pipelineId + publishNo + projectId(校验位)
    }
}
